export default class StrUtil {
    static id = 1000
    /**
     * 获取唯一id
     */
    static getId = () => {
        this.id++
        return 'uid-' + this.id + ''
    }
    /**
     * 判断内容是否为空
     */
    static isNull(str: any) {
        if (str instanceof Array) return str.length == 0
        if (
            str !== null &&
            str !== 'null' &&
            str !== undefined &&
            str !== 'undefined' &&
            str !== '' &&
            str + '' !== 'NaN'
        )
            return false
        return true
    }

    static getImageExtension(imagePath: string): string | null {
        const extensionRegex = /\.(png|jpe?g)$/i
        if (extensionRegex.test(imagePath)) {
            const match = imagePath.match(extensionRegex)
            if (match && match.length > 1) {
                return match[1].toLowerCase()
            }
        }
        return null
    }
}
